405C - Unusual Product - CodeForces Solution


implementation math *1600

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(s) (int)s.size()
#define all(v) (v).begin(),(v).end()
#define fx(x) fixed<<setprecision(x);
#define SKADOOSH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const double PI = acos(-1.0);


void file()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    SKADOOSH;
    int n;
    cin>>n;
    vector<int>v(n);
    int sum=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            bool che;
            cin>>che;
            if(i==j)
            {
                v[i]=che;
                sum+=v[i];
            }
        }
    }
    int m;
    cin>>m;
    while(m--)
    {
        int oper;
        cin>>oper;
        if(oper==3)
        {
            cout<<(sum&1);
        }
        else
        {
            int val;
            cin>>val;
            if(v[val-1])
                sum--;
            else
                sum++;
            v[val]=!v[val];
        }
    }
}


Comments

Submit
0 Comments
More Questions

762C - Two strings
802M - April Fools' Problem (easy)
577B - Modulo Sum
1555B - Two Tables
1686A - Everything Everywhere All But One
1469B - Red and Blue
1257B - Magic Stick
18C - Stripe
1203B - Equal Rectangles
1536A - Omkar and Bad Story
1509A - Average Height
1506C - Double-ended Strings
340A - The Wall
377A - Maze
500A - New Year Transportation
908D - New Year and Arbitrary Arrangement
199A - Hexadecimal's theorem
519C - A and B and Team Training
631A - Interview
961B - Lecture Sleep
522A - Reposts
1166D - Cute Sequences
1176A - Divide it
1527A - And Then There Were K
1618E - Singers' Tour
1560B - Who's Opposite
182B - Vasya's Calendar
934A - A Compatible Pair
1618F - Reverse
1684C - Column Swapping